// 示例：此文件为 订单相关的接口
import axios from "@/utils/axios";

// 添加订单信息
function addOrder(goods_info, addr_id, cart_id) {
    return axios({
        method: "post",
        url: "/api/order",
        data: {
            project_id: 217,
            goods_info: goods_info,
            addr_id: addr_id,
            shoppingCartIds: cart_id,
        },
        headers: { "x-token": localStorage.getItem("token") },
    });
}
// 支付订单
function payOrder(id) {
    return axios({
        method: "post",
        url: "/api/order/pay",
        data: {
            project_id: 217,
            id: id,
            status: 1,
        },
        headers: { "x-token": localStorage.getItem("token") },
    });
}
// 获取订单列表
function getOrderList() {
    return axios({
        method: "get",
        url: "/api/order",
        params: {
            project_id: 217,
            page: 1,
            limit: 20,
            // order_id: 1657954817417,
            status: 0,
            start: "1970-01-01",
            end: "9999-12-31",
        },
        headers: { "x-token": localStorage.getItem("token") },
    });
}

// 删除订单
function deleteOrder(id) {
    return axios({
        method: "delete",
        url: `/api/order/${id}`,
        data: {
            project_id: 217,
        },
        headers: { "x-token": localStorage.getItem("token") },
    });
}

// 获取单条订单信息
function getSingleOrder(id) {
    return axios({
        method: "get",
        url: `/api/order/${id}`,
        headers: { "x-token": localStorage.getItem("token") },
    });
}

export { addOrder, getOrderList, deleteOrder, payOrder, getSingleOrder };
